﻿function checkForm(){
		var name=document.getElementById("name");
		var userName=document.getElementById("userName");
		var pwd=document.getElementById("password");
		var repwd=document.getElementById("repassword");
		var depart=document.getElementById("depart");
		var job=document.getElementById("job");
		if(userName.value.trim()==""){
			alert("用户名不能为空！");
			userName.focus();
			return false;
		}else if(pwd.value.trim().length<6){
			alert("请输入6-20的密码！");
			pwd.focus();
			return false;
		}else if(repwd.value.trim()!=pwd.value.trim()){
			alert("确认密码和密码不一至，请重新输入！");
			repwd.focus();
			return false;
		}else if(name.value.trim()==""){
			alert("姓名不能为空！");
			name.focus();
			return false;
		}else if(depart.value.trim()==""){
			alert("所属部门不能为空！");
			depart.focus();
			return false;
		}else{}
		return sendCode();
	}
	function setSonCHK(o,type){
		var dls=o.parentNode.parentNode.getElementsByTagName("dd");
		for(var i=0;i<dls.length;i++){
			var inputs=dls[i].getElementsByTagName("input");
			if(type===0){
				inputs[0].checked=o.checked;
			}else{
				if(o.checked){
					o.parentNode.getElementsByTagName("input")[0].checked=true;
					inputs[0].checked=o.checked;
				}
				inputs[1].checked=o.checked;
			}
		}
 }
 function sendCode(){
	var reads=document.getElementsByName("readCode");
	var edits=document.getElementsByName("editCode");
	var readCode="",editCode="";
	for(var i=0;i<reads.length;i++){
		if(reads[i].checked){
			if(readCode!="")readCode+=",";
			readCode+=reads[i].value;
		}
		if(edits[i].checked){
			if(editCode!="")editCode+=",";
			editCode+=edits[i].value;
		}
	}	
	if($E("allSet").checked){
		$E("partCode").value="ALL";
		return true;
	}else{
		if(readCode==""){
			alert("必须为账户设置初始权限！");
			return false;
		}else{
			$E("partCode").value=editCode+","+readCode;
			return true;
		}	
	}
 }
 function autoSetRead(o){
	if(o.checked){
		o.parentNode.getElementsByTagName("input")[0].checked=true;
	}	
 }
 function setAll(o){
	var isok=false;
 	if(o.checked){
		isok=true;
	}
	var edits=document.getElementsByName("editCode");
	var reads=document.getElementsByName("readCode");
	var parentReads=document.getElementsByName("parentRead");
	var parentEdits=document.getElementsByName("parentEdit");
	for(var i=0;i<edits.length;i++){
		edits[i].disabled=isok;
		reads[i].disabled=isok;
	}
	for(var i=0;i<parentEdits.length;i++){
		parentEdits[i].disabled=isok;
		parentReads[i].disabled=isok;
	}
 }